function debounce(fn, delay) {
    let timer = null
    return function() {
        clearTimeout(timer)
        let arg = arguments
        timer = setTimeout(() => fn.call(this, arg), delay)
    }
}